precision mediump float;

varying vec2 v_TexCoord;
uniform sampler2D u_Texture;
uniform float u_Offset;
uniform float u_Kernel[25];
uniform int u_KernelSize;

void main() {
    vec4 color = vec4(0.0);
    // gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
    int halfSize = u_KernelSize / 2;
    for(int i = -halfSize; i <= halfSize; i++) {
        for(int j = -halfSize; j <= halfSize; j++) {
            float weight = u_Kernel[(i + halfSize) * u_KernelSize + (j + halfSize)];
            color += texture2D(u_Texture, v_TexCoord + vec2(float(i) * u_Offset, float(j) * u_Offset)) * weight;
        }
    }
    
    gl_FragColor = color;
}